package org.xzy.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

public class ESTest_Index_Delete {

    public static void main(String[] args) throws Exception{

        //创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1",9200))
        );

        //删除索引
        DeleteIndexRequest indexRequest = new DeleteIndexRequest("student");
        AcknowledgedResponse delete = esClient.indices().delete(indexRequest, RequestOptions.DEFAULT);

        System.out.println(delete.isAcknowledged());

        //关闭ES客户端
        esClient.close();

    }
}
